<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <script>
    
        var name = "ZCM";

        // var obj = {
        //     name: name
        // }

        //1. 如果对象中属性名和要给属性赋值的变量同名，则可以省略:以及后面的变量名
        //2. 方法也可以简写， 直接将:function省略掉即可

        var obj = {
            name,
            age: 18,
            sayHi(a, b){
                console.log(a + b)
            }
        }

        obj.sayHi(1, 2);


        console.log(obj);
    </script>
</body>

</html>